package com.flash.mongodb.controller;

import com.flash.mongodb.domain.RecordLog;
import com.flash.mongodb.domain.StudentLog;
import com.flash.mongodb.service.RecordService;
import com.flash.mongodb.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @description: TODO
* @author admin
* @date 2023/1/2611:42
* @version 1.0
*/
@RequestMapping("/stu")
@RestController
public class StuController {

    @Autowired
    StuService stuService;

    @Autowired
    RecordService recordService;

    @GetMapping("/cs")
    public List<StudentLog> getAll(){
        List<StudentLog> all = stuService.getAll();
        return all;
    }

    @GetMapping("/cs2")
    public List<RecordLog> getRecord(){
        List<RecordLog> recor = recordService.getRecor();
        return recor;
    }

    @PostMapping("/save")
    public void save(@RequestBody RecordLog recordLog){
     /*  recordLog.set_id("1");
        recordLog.setContent("l");
        recordLog.setRecordtime("1");
        recordLog.setUsername("哈哈");*/
        recordService.save(recordLog);
    }

    @GetMapping("test")
    public String test(){
        System.out.println("成功");
        return "称呼";
    }

    @GetMapping("de")
    public void de(){
        recordService.delete();
    }
}
